package com.yuxi;

/**
 * Created by yuxi on 17/1/28.
 */
public class Test {
    public synchronized static void test1() {
        try {
            System.out.println(Thread.currentThread().getName() + "..." + System.currentTimeMillis());
            Thread.sleep(5000);
            System.out.println(Thread.currentThread().getName() + "..." + System.currentTimeMillis());
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }

    public synchronized static void test2() {
        try {
            System.out.println(Thread.currentThread().getName() + "..." + System.currentTimeMillis());
            Thread.sleep(4000);
            System.out.println(Thread.currentThread().getName() + "..." + System.currentTimeMillis());
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }

    public synchronized void test3() {
        try {
            System.out.println(Thread.currentThread().getName() + "..." + System.currentTimeMillis());
            Thread.sleep(3000);
            System.out.println(Thread.currentThread().getName() + "..." + System.currentTimeMillis());
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }

    public synchronized void test4() {
        try {
            System.out.println(Thread.currentThread().getName() + "..." + System.currentTimeMillis());
            Thread.sleep(2000);
            System.out.println(Thread.currentThread().getName() + "..." + System.currentTimeMillis());
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }
}
